#ifndef X_1_H
#define X_1_H

#include "cadence_fp.h"
#include "common.h"

// Line segment (with some curve, I think)
template <AllegroVersion version>
struct x01
{
    uint16_t t;
    uint8_t un0;
    
    // Determines whether the shape extends outwards or cuts into the shape.
    uint8_t subtype;
    
    uint32_t k;
    
    uint32_t next;
    uint32_t parent;
    
    // Some bit mask?
    uint32_t un1;
    
    // New in 17.2
#if __cplusplus >= 202002L
    COND_FIELD(version >= A_172, uint32_t, un6);
#endif
    uint32_t width;
    
    // Start and end coordinates
    int32_t coords[4];
    
    cadence_fp x;
    cadence_fp y;
    cadence_fp r;
    
    int32_t bbox[4];
    
    uint32_t TAIL;
    operator x01<A_174>() const;
    static constexpr AllegroVersion versions[1] = {A_172};
};

#if __cplusplus < 202002L
template <> struct x01<A_172>
{
    uint16_t t;
    uint8_t un0;

    // Determines whether the shape extends outwards or cuts into the shape.
    uint8_t subtype;

    uint32_t k;

    uint32_t next;
    uint32_t parent;

    // Some bit mask?
    uint32_t un1;

    // New in 17.2
    uint32_t un6;

    uint32_t width;

    // Start and end coordinates
    int32_t coords[4];

    cadence_fp x;
    cadence_fp y;
    cadence_fp r;

    int32_t bbox[4];

    uint32_t TAIL;
    operator x01<A_174>() const;
    static constexpr AllegroVersion versions[1] = {A_172};
};

template<> struct x01<A_174> : x01<A_172> {};
#endif

static_assert(sizeof_until_tail<x01<A_160>>() == 80);
static_assert(sizeof_until_tail<x01<A_172>>() == 84);
static_assert(sizeof_until_tail<x01<A_174>>() == 84);

#endif // X_1_H
